#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>


#define PLUGIN_VERSION "1.0"

public Plugin myinfo =
{
	name = "l4d2_no_bot_door",
	author = "豆瓣酱な",
	description = "阻止bot开启或关闭安全门.",
	version = PLUGIN_VERSION,
	url = "https://gitee.com/sweet-and-sour-bombs/adfvsdsd"
};

public void OnPluginStart()
{
	HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
}

public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
	CreateTimer(0.5, Timer_HookDoors, _, TIMER_FLAG_NO_MAPCHANGE);
}

public Action Timer_HookDoors(Handle timer)
{
	int entity = -1;
	while ((entity = FindEntityByClassname(entity, "prop_door*")) != -1)
	{
		SDKHook(entity, SDKHook_Use, OnDoorUsed);
	}
	return Plugin_Stop;
}

public Action OnDoorUsed(int door, int activator, int caller, UseType type, float value)
{
	if (activator > 0 && activator <= MaxClients && IsFakeClient(activator))
	{
		return Plugin_Handled;
	}
	return Plugin_Continue;
}